package com.woniuxy.web.exception;



import com.woniuxy.core.exception.accountException.AccountException;
import com.woniuxy.core.exception.authenticationException.AuthenticationException;
import com.woniuxy.core.exception.certifiedException.CertifiedException;
import com.woniuxy.core.exception.entranceException.EntranceException;
import com.woniuxy.core.exception.orderException.OrderException;
import com.woniuxy.core.exception.platformException.PlatformException;
import com.woniuxy.core.exception.rentersException.RentersException;
import com.woniuxy.core.exception.stallException.StallException;
import com.woniuxy.core.model.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class GolbalExcpetion {



    @ExceptionHandler(CertifiedException.class)
    public Result<?> CertifiedException(CertifiedException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(PlatformException.class)
    public Result<?> PlatformException(PlatformException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(AccountException.class)
    public Result<?> AccountException(AccountException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(AuthenticationException.class)
    public Result<?> AuthenticationException(AuthenticationException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(StallException.class)
    public Result<?> StallException(StallException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(OrderException.class)
    public Result<?> OrderException(OrderException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(EntranceException.class)
    public Result<?> EntranceException(EntranceException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(RentersException.class)
    public Result<?> RentersException(RentersException e){
        e.printStackTrace();
        return  Result.getResult().setMessage(e.getMessage()).setCode(e.getCode());
    }

    @ExceptionHandler(Throwable.class)
    public Result<?> throwAbleException(Throwable throwable){
        throwable.printStackTrace();
        return  Result.getResult(Throwable.class).setMessage("系统异常").setCode(500);
    }


}
